const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin') 
const {CleanWebpackPlugin} = require('clean-webpack-plugin')
module.exports = {
  entry: {
    main: './main.js', // 入口文件
    index: './index.js', // 多入口文件
  },
  output: {
    path: path.join(__dirname, 'dist'),
    filename: '[name].js', // 出口文件
  },
  mode: 'development', // 开发环境
  module: {
    rules: [
      {
        test: /\*.js$/,
        use: {
          loader: "babel-loader"
        }
      },
      {
        test: /\.less$/i,
        use: [
          "style-loader",
          "css-loader",
          "less-loader",
        ]
      }
    ]
  },
  plugins: [
    new CleanWebpackPlugin (),
    new HtmlWebpackPlugin({
      chunks: ['main'],
      template: './index.html'
    })
  ]
}